//
//  OAApprovelistManagerVC.m
//  OA项目
//
//  Created by innofive on 2018/4/13.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAApprovelistManagerVC.h"
#import "MCSwitchTabControl.h"
#import "MainTabBarViewController.h"
#import "OAApprovelistCell.h"
#import "OAApproveDetailsVC.h"
#import "OAApproveRejectedVC.h"
@interface OAApprovelistVC ()

@end

@implementation OAApprovelistVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}

-(void)onLoadViewByWillAppear:(UITableView *)view
{
    view.backgroundColor = hexCOLOR(@"F1F1F1");
    view.separatorStyle = UITableViewCellSeparatorStyleNone;
}

-(void)onLoadDataForPageNum:(NSInteger)pageNum
{
    
    NSArray *ar =@[self.Id];
    WSELF(weakSelf);
    [ENGINE POST:@"/oa/v1.0/todoListModule/approveList" param:@{
                                                                @"pageNum":@(pageNum),
                                                                @"pageSize":@10,
                                                                @"q":@"",
                                                                @"cateIds":ar
                                                                } parseClass:nil successBlock:^(id data) {
        
    } falieBlock:self.failedBlock errorBlock:self.errorBlock];

}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 10;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
    return [MCCellInfo configForCellId:cell Class:[OAApprovelistCell class] Height:kFitH(85) TableView:tableView];
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView FooderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:foodter Class:[OAApprovelistFooder class] Height:kFitH(70) TableView:tableView];
}

#pragma mark 点击方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self onSelectVCForIndexPath:indexPath];
}
-(void)onSelectFooder:(UITapGestureRecognizer *)tapGestureRecognizer
{
    OAApprovelistFooder *fooderView = (OAApprovelistFooder *)[tapGestureRecognizer view];
    
    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:fooderView.section];
    
    [self onSelectVCForIndexPath:indexPath];
}


-(void)onSelectVCForIndexPath:(NSIndexPath *)indexPath
{
    id model = [self modelForIndexPath:indexPath];
    OAApproveDetailsVC *vc = [[OAApproveDetailsVC alloc]initWithStyle:(UITableViewStylePlain)];
    vc.title = @"请假单";
    [self pushToVC:vc model:model];
}
-(void)onClick:(UIButton *)button
{
    OAApproveRejectedVC *vc =[OAApproveRejectedVC rejectedVCForType:button.tag==10?openVCTypeOne:openVCTypeTwo];
    
    [self presentWindowToVC:vc IsNaV:NO Completion:^{
        
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end




@interface OAApprovelist1VC ()

@end

@implementation OAApprovelist1VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}

-(void)onLoadDataForPageNum:(NSInteger)pageNum
{
    
    NSArray *ar =@[self.Id];
    WSELF(weakSelf);
    [ENGINE POST:@"/oa/v1.0/transactListModule/transactList" param:@{
                                                                @"pageNum":@(pageNum),
                                                                @"pageSize":@10,
                                                                @"q":@"",
                                                                @"cateIds":ar
                                                                } parseClass:nil successBlock:^(id data) {
                                                                    
                                                                } falieBlock:self.failedBlock errorBlock:self.errorBlock];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end





@interface OAApprovelist2VC ()

@end

@implementation OAApprovelist2VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView FooderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:foodter Class:[BaseTableViewHeaderFooterView class] Height:kFitH(10) TableView:tableView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end




@interface OAApprovelist3VC ()

@end

@implementation OAApprovelist3VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end





@interface OAApprovelistManagerVC ()<panGestureRecognizerDelegate>
@property(nonatomic,strong)MainTabBarViewController *tabBarC;
@property(nonatomic,strong)MCSwitchTabControl *tabControl;

@end

@implementation OAApprovelistManagerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    OAApprovelistVC  *vc  = [[OAApprovelistVC alloc]initWithStyle:(UITableViewStyleGrouped)];
    vc.taskType = @"D";
    vc.Id = self.Id;
//    vc.view.backgroundColor = [UIColor yellowColor];
    
    OAApprovelist1VC *vc1 = [[OAApprovelist1VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    vc1.taskType = @"J";
    vc1.Id = self.Id;
//    vc1.view.backgroundColor = [UIColor redColor];
    
//    OAApprovelist2VC *vc2 = [[OAApprovelist2VC alloc]initWithStyle:(UITableViewStyleGrouped)];
//    vc2.view.backgroundColor = [UIColor brownColor];
    
//    OAApprovelist3VC *vc3 = [[OAApprovelist3VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    
    NSArray *vcs = @[vc,vc1];
    MainTabBarViewController *tabBarC = [MainTabBarViewController new];
    tabBarC.panGestureDelegate = self;
    tabBarC.tabBar.hidden = YES;
    tabBarC.viewControllers = vcs;
    [self addChildViewController:tabBarC];
    [self.view addV:tabBarC.view];
    _tabBarC = tabBarC;
}

-(void)onLoadViewByWillAppear:(UIView *)view
{
    MCSwitchTabControl *v = [MCSwitchTabControl new];
    [v addTarget:self action:@selector(onClickChangeBtn:) forControlEvents:UIControlEventValueChanged];
    [v insertSegmentWithTitle:@"待审核" image:nil];
    [v insertSegmentWithTitle:@"已审批" image:nil];
//    [v insertSegmentWithTitle:@"已驳回" image:nil];
//    [v insertSegmentWithTitle:@"全部" image:nil];
    [view addV:v];
    _tabControl = v;
    WSELF(weakSelf);
    [self onMainQueueAddSub:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        v.frame = CGRectMake(0, 0, size.width,kFitH(45));
        weakSelf.tabBarC.view.frame = CGRectMake(0,kFitH(45),size.width,size.height-kFitH(45));
    }];
}

-(void)onClickChangeBtn:(MCSwitchTabControl *)button
{
    self.tabBarC.selectedIndex = button.selectedSegmentIndex;
    [button segmentLineScrollToIndex:button.selectedSegmentIndex animate:YES];
}

-(void)tabBarViewController:(MainTabBarViewController *)tabBarViewController SelectedIndex:(NSInteger)selectedIndex
{
    _tabControl.selectedSegmentIndex =selectedIndex;
    [_tabControl segmentLineScrollToIndex:selectedIndex animate:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end





